<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/jquery-easyui-1.8.6/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/jquery-easyui-1.8.6/themes/icon.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.8.6/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.8.6/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.8.6/jquery.edatagrid.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.8.6/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/common.js"></script>
    <script type="text/javascript">

        $(function () {

            $.post("${pageContext.request.contextPath}/saleChance/findById.do", {id: '${param.saleChanceId}'}, function (result) {
                $("#customerName").textbox("setValue", result.customerName);
                $("#chanceSource").textbox("setValue", result.chanceSource);
                $("#linkMan").textbox("setValue", result.linkMan);
                $("#linkPhone").textbox("setValue", result.linkPhone);
                $("#cgjl").numberbox("setValue", result.cgjl);
                $("#overView").textbox("setValue", result.overView);
                $("#description").textbox("setValue", result.description);
                $("#createMan").textbox("setValue", result.createMan);
                $("#createTime").textbox("setValue", result.createTime);
                $("#assignMan").textbox("setValue", result.assignMan);
                $("#assignTime").textbox("setValue", result.assignTime);
            }, "json");

            $("#dg").edatagrid({
                url: '${pageContext.request.contextPath}/cusDevPlan/list.do?saleChanceId=${param.saleChanceId}',
                saveUrl: '${pageContext.request.contextPath}/cusDevPlan/save.do?saleChance.id=${param.saleChanceId}',
                updateUrl: '${pageContext.request.contextPath}/cusDevPlan/save.do?saleChance.id=${param.saleChanceId}',
                destroyUrl: '${pageContext.request.contextPath}/cusDevPlan/delete.do',
                autoSave: true,
                destroyMsg:{
                    norecord:{	// when no record is selected
                        title:'警告',
                        msg:'没有数据被选择。'
                    },
                    confirm:{	// when select a row
                        title:'确认',
                        msg:'确认要删除吗?'
                    }
                },
                onSave: function (index, row) {
                    // $('#dg').edatagrid('reload');
                },
                onDestroy: function (index, row) {
                    // $('#dg').edatagrid('reload');
                },
                onError: function (index, row) {
                    // 'isError' 属性设置为 true 的行
                    // $('#dg').edatagrid('reload');
                },
                onLoadSuccess: function () {
                    //加载成功
                },
            });

            if(${param.editable == false}){
                $(".easyui-linkbutton").linkbutton("disable");
                $("#dg").edatagrid("disableEditing");
            }
        });

        function updateSaleChanceDevResult(devResult) {
            $.post("${pageContext.request.contextPath}/cusDevPlan/updateSaleChanceDevResult.do", {id: '${param.saleChanceId}', devResult: devResult}, function (result) {
                if (result.success) {
                    $.messager.alert("系统提示", "执行成功！");
                    $(".easyui-linkbutton").linkbutton("disable")
                } else {
                    $.messager.alert("系统提示", "执行失败！");
                }
            }, "json");
        }
    </script>
    <title>开发计划项管理</title>
</head>
<body class="easyui-layout" fit="true">
<div region="center" title="销售机会信息">
    <table cellspacing="8px">
        <tr>
            <td>客户名称：</td>
            <td><input id="customerName" name="customerName" class="easyui-textbox" editable="false"/></td>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>机会来源</td>
            <td><input id="chanceSource" name="chanceSource" class="easyui-textbox" editable="false"/></td>
        </tr>
        <tr>
            <td>联系人：</td>
            <td><input id="linkMan" name="linkMan" class="easyui-textbox" editable="false"/></td>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>联系电话：</td>
            <td><input id="linkPhone" name="linkPhone" class="easyui-textbox" editable="false"/></td>
        </tr>
        <tr>
            <td>成功几率(%)：</td>
            <td><input id="cgjl" name="cgjl" class="easyui-numberbox" editable="false"/></td>
            <td colspan="3">&nbsp;&nbsp;&nbsp;&nbsp;</td>
        </tr>
        <tr>
            <td>概要：</td>
            <td colspan="4"><input id="overView" name="overView" style="width: 420px;height:66px" class="easyui-textbox" editable="false" multiline="true"/></td>
        </tr>
        <tr>
            <td>机会描述：</td>
            <td colspan="4">
                <input id="description" name="description" class="easyui-textbox" editable="false" multiline="true" style="width: 420px;height:66px">
            </td>
        </tr>
        <tr>
            <td>创建人：</td>
            <td><input class="easyui-textbox" editable="false" id="createMan" name="createMan"/></td>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>创建时间：</td>
            <td><input class="easyui-textbox" editable="false" id="createTime" name="createTime"/></td>
        </tr>
        <tr>
            <td>指派给：</td>
            <td>
                <input class="easyui-textbox" editable="false" id="assignMan" name="assignMan"/>
            </td>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>指派时间：</td>
            <td><input class="easyui-textbox" editable="false" id="assignTime" name="assignTime"/></td>
        </tr>
    </table>
</div>
<div region="east" title="开发计划项" style="width: 700px">
    <table id="dg" idField="id" fit="true" rownumbers="true" fitColumns="true" singleSelect="true"
           toolbar="#toolbar">
        <thead>
        <tr>
            <th field="id" width="50" hidden="true">编号</th>
            <th field="planDate" width="50" editor="{type:'datebox',options:{required:true}}">日期</th>
            <th field="planItem" width="100" editor="{type:'validatebox',options:{required:true}}">计划内容</th>
            <th field="exeAffect" width="100" editor="{type:'validatebox',options:{required:true}}">执行效果</th>
        </tr>
        </thead>
    </table>

    <div id="toolbar">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="javascript:$('#dg').edatagrid('addRow')">添加计划</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="javascript:$('#dg').edatagrid('destroyRow');">删除计划</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="javascript:$('#dg').edatagrid('saveRow')">保存计划</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="javascript:$('#dg').edatagrid('cancelRow')">撤销行</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-kfcg" plain="true" onclick="updateSaleChanceDevResult(2)">开发成功</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-zzkf" plain="true" onclick="updateSaleChanceDevResult(3)">终止开发</a>
    </div>
</div>

</body>
</html>